home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / System / CAnimCursor & Friends / CAcurSwitchboard.c < prev    next >
Text File  |  1992-05-20  |  2KB  |  111 lines

  1. /*
  2.  * CAcurSwitchboard.c
  3.  * A useful supplement to CAnimCursor, when using the TCL.
  4.  * Version 1.0b3, 13 May 1992
  5.  *
  6.  * To use, change your application's MakeSwitchboard() method to:
  7.  *
  8.  *        void CYourApp::MakeSwitchboard(void)
  9.  *        {
  10.  *            itsSwitchboard = new(CAcurSwitchboard);
  11.  *            ((CAcurSwitchboard*)itsSwitchboard)->IAcurSwitchboard();
  12.  *        }
  13.  *
  14.  * If the switchboard you're presently using is not the standard
  15.  * CSwitchboard, see the note about multiple inheritance in
  16.  * CDesktop.c.
  17.  *
  18.  */
  19.  
  20.  
  21.  
  22. /********************************/
  23.  
  24. #include "CAcurSwitchboard.h"
  25.  
  26. /********************************/
  27.  
  28. #include <CWindow.h>
  29.  
  30. #include "CAnimCursor.h"
  31.  
  32. /********************************/
  33.  
  34.  
  35.  
  36. void CAcurSwitchboard::IAcurSwitchboard(void)
  37. {
  38.     inherited::ISwitchboard();
  39. }
  40.  
  41.  
  42.  
  43. void CAcurSwitchboard::ProcessEvent(void)
  44. {
  45.     if (gAnimCursor != NULL) {
  46.         
  47.         Boolean shouldStopAnimating = FALSE;
  48.         
  49.         if (gAnimCursor->getMode() == kCACModeInterrupted) {
  50.             
  51.             shouldStopAnimating = TRUE;
  52.             
  53.         } else {
  54.             
  55.             WindowPeek theFrontWindow = (WindowPeek) FrontWindow();
  56.             
  57.             switch (theFrontWindow->windowKind) {
  58.             
  59.             case dialogKind: // a dialog or alert
  60.                 shouldStopAnimating = TRUE;
  61.                 break;
  62.                 
  63.             case OBJ_WINDOW_KIND: { // a TCL window
  64.                 CWindow *theWindow;
  65.                 theWindow = (CWindow*) GetWRefCon((WindowPtr) theFrontWindow);
  66.                 if (theWindow->IsModal()) {
  67.                     shouldStopAnimating = TRUE;
  68.                 }
  69.             }    break;
  70.                 
  71.             default:
  72.                 break;
  73.             }
  74.             
  75.         }
  76.         
  77.         if (shouldStopAnimating) {
  78.             gAnimCursor->stopAnimating();
  79.         }
  80.     }
  81.     
  82.     inherited::ProcessEvent();
  83. }
  84.  
  85.  
  86.  
  87. void CAcurSwitchboard::DispatchEvent(EventRecord *macEvent)
  88. {
  89.     if (gAnimCursor == NULL || !gAnimCursor->getIsAnimating()) {
  90.         
  91.         inherited::DispatchEvent(macEvent);
  92.         
  93.     } else {
  94.         
  95.         switch (macEvent->what) {
  96.             case mouseUp:
  97.             case mouseDown:
  98.             case keyDown:
  99.             case keyUp:
  100.             case autoKey:
  101.             case diskEvt:
  102.             case osEvt:
  103.                 gAnimCursor->stopAnimating();
  104.             default:
  105.                 inherited::DispatchEvent(macEvent);
  106.                 break;
  107.         }
  108.         
  109.     }
  110. }
  111.